import { lazy } from 'react'
const PickFolder = lazy(()=>import('#cpt/form-element/pick-folder'))
const data = [
	{ label:'备份数据和结构', value: 0 },
	{ label:'仅备份表数据', value: 1 },
	{ label:'仅备份表结构', value: 2 }
]
/* -------------------------------------------------------- 备份数据库 -- */
const Index = ({ database, backup }) => {
	return {
		modal:{
			title: <span>备份【<b className='c3'>{ database }</b>】数据库</span>,
			width 	: '35%',
		},
		form: {
			labelWidth: 's5',
			api: 'mysql/backup_database',
			infoApi : false,
			param: { path:backup, database, name:Array.isArray(database) ? database.join('-') : database, pwd:'123456', type:0 },
			setParam: ({ database, name }) => ({ 
				database: Array.isArray(database) ? database : [ database ], 
				name: Array.isArray(name) ? name.join('-') : name
			}),
			data: [
				{ label: '数据库', name:'database', r:1, type:'select', api:'project/database', idStr:'database', nameStr:'database', change:({value,ref, row})=>{
					ref.setValue({ name: value, path: row.backup })
				} },
				{ label: '文件名', name:'name', r:1 },
				{ label: '密码', name:'pwd', type:'password', r:1 },
				{ label: '文件夹',  name: 'path', slot: v => <PickFolder {...v}/>, api:'/file/pick_folder',r:1},
				{ label: '备份类型', name:'type', type:'select', data },
			]
		}
	}
}
export default Index